export default class SpuConvertor {
  /**
   *
   * @param categoryId
   * @param formData
   * @param spuDetail SpuDetailEntity
   * @returns {{}}
   */
  static toSpuCreateCmd(categoryId, formData, spuDetail) {
    const result = {}
    // 叶子节点
    result.leafCategoryId = categoryId
    Object.assign(result, formData)
    result.skuList = spuDetail.salePropList.getSkuList()
    // 商品属性
    result.spuPropList = spuDetail.propList.getSpuPropList()
    result.salePropSource = spuDetail.salePropSource
    return result
  }

  static toSpuUpdateCmd(id, formData, spuDetail) {
    const result = {}
    result.id = id
    Object.assign(result, formData)
    result.skuList = spuDetail.salePropList.getSkuList()
    // 商品属性
    result.spuPropList = spuDetail.propList.getSpuPropList()
    result.salePropSource = spuDetail.salePropSource
    delete result.salePropList
    delete result.propList
    delete result.catNames
    return result
  }
}
